package LinkedList和HashSet和HashMap.work02;

import java.util.Iterator;
import java.util.LinkedList;

public class work {
    public static void main(String[] args) {
        String[] str = {"12345","67891","12347809933","67891","12347809933"};
        LinkedList<String> list = new LinkedList<>();
        for (int i = 0; i < str.length; i++) {
            list.add(str[i]);
        }
        System.out.println("删除前：");
        for (String s : list) {
            System.out.println(s);
        }
        System.out.println("--------------------------");
        for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < list.size(); j++) {
                if (list.get(i).equals(list.get(j))){
                    list.remove(j);
                }
            }
        }
        System.out.println("删除后：");
        System.out.println("迭代器循环打印list集合");
        Iterator<String> it = list.iterator();
        while (it.hasNext()){
            String next = it.next();
            System.out.println(next);
        }
        System.out.println("--------------------");
        System.out.println("增强for循环打印list集合");
        for (String s : list) {
            System.out.println(s);
        }
    }
}
